/*
 * @lc app=leetcode.cn id=101 lang=javascript
 *
 * [101] 对称二叉树
 */

// @lc code=start
/**
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */
var isSymmetric = function(root) {
    if(!root){return true}
    let queue=[root.left,root.right]
    while(queue.length){
        let left=queue.shift()
        let right=queue.shift()
        if(!left&&!right){continue}
        if(!left||!right){return false}
        if(left.val==right.val){
            queue.push(left.left)
            queue.push(right.right)
            queue.push(left.right)
            queue.push(right.left)
        }else{
            return false
        }        
        
    }
    return true
};  
// @lc code=end

